package tcp;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.rmi.ConnectException;

public class TcpIpClient {

    public static void main(String args[]){
        try{
            String serverIp = "127.0.0.1";
            
            System.out.println("서버연결");
            
            Socket socket;
            socket = new Socket(serverIp, 7777);

            InputStream in = socket.getInputStream();
            DataInputStream dis = new DataInputStream(in);
            
            System.out.println("서버로부터 받은 메시지" + dis.readUTF());
            System.out.println("접속종료");
            
            dis.close();
            socket.close();
            System.out.println("연결종료");
            
        }catch(ConnectException ce){
            ce.printStackTrace();
        }catch (IOException ie) {
            // TODO Auto-generated catch block
            ie.printStackTrace();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
